package view;

import hxd.Key;
import hxd.Event.EventKind;
import h2d.domkit.Object;
import h2d.Flow;



//类名必须是 uicomp的名字 + Comp (Comp之前每一个大写单词用-链接)
@:uiComp("button")
class ButtonComp extends Flow implements h2d.domkit.Object {

	static var SRC = 
	<button>
		<text text={str} public id="labelTxt" font="font/custom.fnt"/>
	</button>

	public var label(get, set): String;
	function get_label() return labelTxt.text;
	function set_label(s) {
		labelTxt.text = s;
		return s;
	}

	public function new(str:String, ?parent ) {
		super(parent);
		initComponent();
		enableInteractive = true;
		interactive.onClick = function(_) onClick();
		interactive.onOver = function(_) {
			dom.hover = true;
		};
		interactive.onPush = function(_) {
			dom.active = true;
		};
		interactive.onRelease = function(_) {
			dom.active = false;
		};
		interactive.onOut = function(_) {
			dom.hover = false;
		};
	}

	public dynamic function onClick() {
	}
}

@:uiComp("line")
class LineComp extends Flow implements Object {
	static var SRC = 
	<line>
	</line>

	public function new(?parent ) {
		super(parent);
		initComponent();
	}
}

@:uiComp("grid")
class GridComp extends Flow implements Object {
	static var SRC = 
	<grid>
	</grid>

	public function new(?parent ) {
		super(parent);
		initComponent();
		enableInteractive = true;
		interactive.onMove = function (e) {
		};
		interactive.onPush = function(_){
			onClick();
		};
	}

	public dynamic function onClick() {
	}
}

